#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 5010;
typedef long long ll;
ll cnt;
struct ss
{
	int x, y;
}p[N];
bool cmp(ss m, ss n)
{
	return m.y < n.y;
}
int main()
{
	int n, s, a, b;
	cin >> n >> s;
	cin >> a >> b;
	for (int i = 1; i <= n; i++)
		cin >> p[i].x >> p[i].y;
	sort(p + 1, p + n + 1, cmp);
	for (int i = 1; i <= n; i++)
	{
		if (p[i].x <= a + b)
		{
			if (s - p[i].y >= 0)
			{
				cnt++;
				s -= p[i].y;
			}
			else
				break;
		}
	}
	cout << cnt << endl;
	return 0;
}